import axios from 'axios'
export function getCoord(address) {
  return new Promise((resolve, reject) => {
    axios.get('https://restapi.amap.com/v3/geocode/geo', {
      params: {
        address: address,
        output: 'JSON',
        key: '7d5e72c77f9c7ec312a45e87d91c6cc9'
      }
    }).then(res => {
      if (res.status == 200) {
        if (res.data.geocodes[0]) {
          resolve(res.data.geocodes[0].location)
        } else {
          reject('您输入的地址查询不到对应的坐标')
        }
      } else {
        throw new Error('查询失败')
      }
    }).catch((err) => {
      reject(err)
    })
  })
}
